


clear
set more off
set scheme s2mono

set seed 2020
********************************************************************************


use "$merge_mobile", clear 


local prefix = 1
forvalues i = -0.5(0.05)0.51 {

	display `i'
	display `prefix'
	kl_cont, ind_var("fin_savings_jan5") treatment("mshwariorlsa") gen("fin_savings_jan5_") prefix(`prefix') sd(`i')
	
local prefix = `prefix' + 1	
}

 
preserve
	clear
	tempfile results
	save `results', replace emptyok
restore 


forvalues i = 1/21{
	preserve
		local varlab: variable label fin_savings_jan5_`i'
		reg fin_savings_jan5_`i' mshwariorlsa i.stratification, vce(cluster b_schoolname_baseline_encoded)
		parmest , norestore
		keep parm estimate min95 max95 p
		keep if parm =="mshwariorlsa"
		gen label = "`varlab'"
		gen var = "fin_savings_jan5_`i'"

		append using `results'
		save `results', replace

	restore
	}

use `results', clear

gen rank = _n

sort label

split label, parse(" ") gen(v)
drop v1 v2 v3 v5 v6
destring v4, replace
gen bs = abs(v4)
sort bs v4
bysort bs (v4): gen j = _n 
egen grp = group(bs)

keep estimate v4 bs j grp

reshape wide estimate v4, i(grp) j(j)

replace estimate2 = estimate1 if estimate2==.

sort bs
gen rank = _n

  
twoway (rcap  estimate2 estimate1 rank, title("Gross Financial Savings (Jan5)") ytitle("OLS Coefficient") ylabel(-1000(1000)4000, angle(0)) yline(0) sort xlabel(1 "0 sd" 3  "0.1 sd" 5 "0.2 sd" 7 "0.3 sd" 9 "0.4 sd" 11 "0.5 sd") xtitle(""))  
		
graph export "$wd/03_output/graph_02b_GrossFinSavings.png", as(png) name("Graph")
